<?php
include dirname(__FILE__) . "/config/functions.php";

if (!isset($_SESSION['advertiseImg']) && !isset($_SESSION['advertiseTxt'])) {
    header('location: advertise.php');
}

$_SESSION['advertise']['payment'] = 'paypal';

if ($_SESSION['advertise']['payment'] == 'paypal') {
    $email = mysql_query("SELECT `value` FROM `option` where `key` = 'paypal_email' ");
    $email = mysql_fetch_assoc($email);
} elseif ($_SESSION['advertise']['payment'] == 'payza') {
    $email = mysql_query("SELECT `value` FROM `option` where `key` = 'payza_email' ");
    $email = mysql_fetch_assoc($email);
} elseif ($_SESSION['advertise']['payment'] == 'egold') {
    $email = mysql_query("SELECT `value` FROM `option` where `key` = 'egold_id' ");
    $email = mysql_fetch_assoc($email);
}
$sitename = mysql_query("SELECT `value` FROM `option` where `key` = 'site_name' ");
$sitename = mysql_fetch_assoc($sitename);
$siteUrl = mysql_query("SELECT `value` FROM `option` where `key` = 'site_url' ");
$siteUrl = mysql_fetch_assoc($siteUrl);


$optionsQuery = mysql_query("SELECT * FROM `option`");
while($row = mysql_fetch_assoc($optionsQuery))    $options[$row['key']] = $row['value'];
  



// impressions
if (isset($_SESSION['advertise']['impUrl'])) {
    $valuePlusPrice = explode("^", $_SESSION['advertise']['credits']);
    $describtion = $valuePlusPrice[0] . " Banner Impressions at " . $sitename['value'] . "!!";
    $price = $valuePlusPrice[1];
    $textAd = null;
    $url = $_SESSION['advertise']['impUrl'];
    $level = null;
    $name = $_SESSION['advertise']['name'];
    $enail = $_SESSION['advertise']['email'];
    $bannerUrl = $_SESSION['advertise']['bannerUrl'];
    $payment = $_SESSION['advertise']['payment'];
    $subscription = 'Impressions';
    $assigned = $_SESSION['advertise']['credits'];
    $password = $_SESSION['advertise']['password'];
    $position = 'top';//$_SESSION['advertise']['position'];
    $qry = "INSERT INTO ads (textAd, url, level, name, email, banner_url, payment_type, status, subscription, assigned, current, tracking_password, created_at, position) 
            VALUES (null, '$url', null, '$name', '$enail', '$bannerUrl', '$payment', 0, '$subscription', '$assigned', 0, '$password', now(), '$position') ";
}
// text Ad
else {
    $valuePlusPrice = explode("^", $_SESSION['advertise']['credits']);
    $describtion = $valuePlusPrice[0] . " Sponsor Ad Hits at " . $sitename['value'] . "!!";
    $price = $valuePlusPrice[1];

    $textAd = $_SESSION['advertise']['textAd'];
    $url = $_SESSION['advertise']['hitUrl'];
    $level = 0;
    $name = $_SESSION['advertise']['name'];
    $enail = $_SESSION['advertise']['email'];
    $bannerUrl = null;
    $payment = $_SESSION['advertise']['payment'];
    $subscription = 'Hits';
    $assigned = $_SESSION['advertise']['credits'];
    $password = $_SESSION['advertise']['password'];
    $qry = "INSERT INTO ads (textAd, url, level, name, email, banner_url, payment_type, status, subscription, assigned, current, tracking_password, created_at) 
            VALUES ('$textAd', '$url', '$level', '$name', '$enail', null, '$payment', 0, '$subscription', '$assigned', 0, '$password', now()) ";
}

// save this account to user table
mysql_query($qry);

?>
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!-- Consider adding a manifest.appcache: h5bp.com/d/Offline -->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title><?= $options['site_name'] ?></title>
        <meta property="og:title" content="<?= $options['site_name'] ?>">
        <meta property="og:site_name" content="<?= $options['site_name'] ?>">
        <meta property="og:type" content="<?= $options['type'] ?>">
        <meta property="og:url" content="<?= $options['url'] ?>">
        <meta property="og:image" content="<?= $options['image'] ?>">
        <meta property="fb:admins" content="<?= $options['admins'] ?>">
        <meta name="description" content="<?= $options['site_description'] ?>">
        <meta name="keywords" content="<?= $options['keywords'] ?>">
        <meta name="author" content="<?= $options['author'] ?>">
        <meta name="Robots" content="<?= $options['Robots'] ?>">
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
        <link href="css/bootstrap.min.css" rel="stylesheet"/>
        <link href="css/style.css" rel="stylesheet"/>
    </head>
    <body>
        <!-- Save for Web Slices (index.psd) -->
        <table width="950" height="1" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
            <tr>
                <td background="images/bg.png">
                    <img src="images/header.png" alt="Viral Marketing Script - Your MEGA Traffic on Over-Drive!" width="950" height="294" lowsrc="Viral Marketing Script - Your MEGA Traffic on Over-Drive!"></td>
            </tr>
            <tr>
                <td background="images/bg.png"><div align="center"><strong><span class="style4">
                                :: <a href="index.php">Home</a> 
                                :: <a href="contact.php">Contact Us</a> 
                                :: <a href="advertise.php">Advertise</a> 
                                :: <a href="member/login.php">Login</a> 
                                ::</span></strong></div>
                </td>
            </tr>
            <tr>
                <td background="images/bg.png">
                    <div align="center">
                        <div class="container"> 
                            <div style="margin: 7px;"> 
                                <?php $_position = 'top'; ?>
                                <?php include dirname(__FILE__) . '/_banner.php'; ?>
                            </div>
                            <div class="row">

                                <div class="main text-center text-page"> 

                                    <?php if (isset($_SESSION['advertiseImg'])): ?>
                                        <div class="text-page-left">
                                            <p align="center" style="font-size: 17px;"><b>You are only 1 step away, just make the payment of the banner impressions and we will activate your banner after approving your payment.</b>
                                        </div>
                                    <?php else: ?>
                                        <div class="text-page-left">
                                            <p align="center" style="font-size: 17px;"><b>You are only 1 step away, just make the payment of the sponsor ads package and we will activate your sponsor ad after approving your payment.</b>
                                        </div>
                                    <?php endif; ?>

                                    <BR>

                                    <?php if ($_SESSION['advertise']['payment'] == 'paypal'): ?>
                                        <form style="margin-left: 39%;" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
                                            <input type="hidden" name="cmd" value="_xclick">
                                            <input type="hidden" name="business" value="<?= $email['value'] ?>">
                                            <input type="hidden" name="lc" value="US">
                                            <input type="hidden" name="item_name" value="<?= $describtion ?>">
                                            <input type="hidden" name="amount" value="<?= $price ?>">
                                            <input type="hidden" name="currency_code" value="USD">
                                            <input type="hidden" name="button_subtype" value="services">
                                            <input type="hidden" name="no_note" value="0">
                                            <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
                                            <input type="image" src="images/paypal.png" border="0" name="submit" alt="" id="paypal">
                                            <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
                                        </form>


                                    <?php elseif ($_SESSION['advertise']['payment'] == 'payza'): ?>
                                        <form action="https://secure.payza.com/checkout" method="post">
                                            <input type="hidden" name="ap_purchasetype" value="Item">
                                            <input type="hidden" name="ap_merchant" value="<?= $email['value'] ?>">
                                            <input type="hidden" name="ap_itemname" value="<?= $sitename['value'] ?> Advertisement">
                                            <input type="hidden" name="ap_currency" value="USD">
                                            <input type="hidden" name="ap_returnurl" value="<?= $siteUrl['value'] ?>">
                                            <input type="image" src="https://secure.payza.com/PayNow/138F4314F461497ABB07823FECBCB02Db4en.gif">
                                            <input type="hidden" name="ap_quantity" value="1">
                                            <input type="hidden" name="ap_description" value="<?= $describtion ?>">
                                            <input type="hidden" name="ap_amount" value="<?= $price ?>">
                                            <input type="hidden" name="ap_cancelurl" value="<?= $siteUrl['value'] ?>">
                                        </form>


                                    <?php elseif ($_SESSION['advertise']['payment'] == 'egold'): ?>
                                        <form method="post" action="https://www.e-gold.com/sci_asp/payments.asp">
                                            <input type="hidden" value="<?= $email['value'] ?>" name="PAYEE_ACCOUNT">
                                            <input type="hidden" value="<?= $sitename['value'] ?>" name="PAYEE_NAME">
                                            <input type="hidden" value="<?= $price ?>" name="PAYMENT_AMOUNT">
                                            <input type="hidden" value="1" name="PAYMENT_UNITS">
                                            <input type="hidden" value="1" name="PAYMENT_METAL_ID">
                                            <input type="hidden" value="<?= $siteUrl['value'] ?>" name="STATUS_URL">
                                            <input type="hidden" value="<?= $siteUrl['value'] ?>" name="NOPAYMENT_URL">
                                            <input type="hidden" value="LINK" name="NOPAYMENT_URL_METHOD">
                                            <input type="hidden" name="PAYMENT_ID" value="<?= $describtion ?>">
                                            <input type="hidden" value="<?= $siteUrl['value'] ?>" name="PAYMENT_URL">
                                            <input type="hidden" value="LINK" name="PAYMENT_URL_METHOD">
                                            <input type="hidden" name="BAGGAGE_FIELDS" value="">
                                            <input type="hidden" value="<?= $describtion ?>" name="SUGGESTED_MEMO">
                                            <input type="image" src="http://www.e-gold.com/gif/paywith.gif" value="submit" border="0" name="I1">
                                        </form>
                                    <?php endif; ?>

                                </div> 
                            </div> 
                            <br>
                            <div style="margin: 25px;"> 
                                <?php $_position = 'bottom'; ?>
                                <?php include dirname(__FILE__) . '/_banner.php'; ?>
                            </div>
                        </div>

                    </div>
                </td>
            </tr>
            <tr>
                <td background="images/bg.png"><div align="center">
                        <?php include dirname(__FILE__) . '/footer.php'; ?>
                    </div></td>
            </tr>
            <tr>
                <td>
                    <img src="images/footer.png" width="950" height="108" alt=""></td>
            </tr>
        </table>
        <script src="js/jquery-1.10.2.min.js"></script>
        <script src="js/bootstrap.min.js"></script>

        <!-- End Save for Web Slices -->
    </body>
</html>    